<?php
require_once 'mysql.php';

$data = file_get_contents('php://input');
$data = json_decode($data, true);
$table = $data['table'];
$id = (string)$data["id"];

// 配置连接参数
$config = [
    'host' => 'localhost',
    'username' => 'username',
    'password' => 'password',
    'dbname' => 'projectDB'
];

// 连接数据库
$mysql = new mysql();

$mysql->connect($config);

$where = 'id=' . $id;

if ($table == 'childrenclass') {
    $result = $mysql->delete($table, $where);
} else if ($table == 'fatherclass') {
    $result = $mysql->delete($table,$where);
    $whereChildren = 'father_id=' . $id;
    $retval = $mysql->delete('childrenclass', $whereChildren);
}

echo $result;

// print_r($mysql->fetchAll());